﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Eassets.UI
{
    public class Global
    {
        public static String KeyLoginUserStakeholderId = "LoginUserStakeholderId";
        public static String KeyLoginUserStakeholderName = "LoginUserStakeholderName";
        public static String KeyLogUserEmail = "LogUserEmail";
        public static String KeyLogUserPassWord = "LogUserPassWord";
        public static String KeyLogUserElectronicSignature = "LogUserElectronicSignature";
        public static String KeyLoginId = "UserLoginId";

        //Company Details
        public static String KeyCurrentCompanyId = "CurrentCompanyId";
        public static String KeyCompanyCode = "CompanyCode";
        public static String KeyDatabaseName = "DatabaseName";
        public static String KeyCurrentCompanyStakeholderId = "CurrentCompanyStakeholderId";

        //Parameter Values
        //--Common Parameters--
        public static String KeyStakeholderTypeForEmployee = "STEMP";
        public static String KeyStakeholderTypeForCorpShRepresentative = "STCRP";
        public static String KeyStakeholderTypeForUserCompany = "STUCP";
        public static String KeyDateFormat = "DTFMT";
        //--eFinance Parameters--
        public static String KeyCashInHand = "CSHAC";
        public static String KeyMiscellaneousIncome = "MISCI";
        public static String KeyMiscellaneousExpence = "MISCE";

        private static string encryptionKey = "@!&%#@?,";

        //public static String Encrypt(string text)
        //{
        //    byte[] iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };

        //    try
        //    {
        //        byte[] bykey = System.Text.Encoding.UTF8.GetBytes(encryptionKey);
        //        byte[] inputByteArray = System.Text.Encoding.UTF8.GetBytes(text);
        //        DESCryptoServiceProvider des = new DESCryptoServiceProvider();
        //        MemoryStream ms = new MemoryStream();
        //        CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(bykey, iv), CryptoStreamMode.Write);
        //        cs.Write(inputByteArray, 0, inputByteArray.Length);
        //        cs.FlushFinalBlock();
        //        return Convert.ToBase64String(ms.ToArray());
        //    }
        //    catch (Exception ex)
        //    {
        //        return ex.Message;
        //    }
        //}

        //public static String Decrypt(string text)
        //{
        //    byte[] iv = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
        //    byte[] inputByteArray = new byte[text.Length];

        //    try
        //    {
        //        byte[] byKey = System.Text.Encoding.UTF8.GetBytes(encryptionKey);
        //        DESCryptoServiceProvider des = new DESCryptoServiceProvider();
        //        inputByteArray = Convert.FromBase64String(text);
        //        MemoryStream ms = new MemoryStream();
        //        CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(byKey, iv), CryptoStreamMode.Write);
        //        cs.Write(inputByteArray, 0, inputByteArray.Length);
        //        cs.FlushFinalBlock();
        //        System.Text.Encoding encoding = System.Text.Encoding.UTF8;
        //        return encoding.GetString(ms.ToArray());
        //    }
        //    catch (Exception exception)
        //    {
        //        return exception.Message;
        //    }
        //}
    }

    /// <summary>
    /// This class is used to compare any
    /// type(property) of a class for sorting.
    /// This class automatically fetches the
    /// type of the property and compares.
    /// </summary>

    //public sealed class GenericComparer<T> : IComparer<T>
    //{

    //    public enum SortOrder { Ascending, Descending };

    //    #region member variables

    //    private string sortColumn;
    //    private SortOrder sortingOrder;

    //    #endregion

    //    #region constructor

    //    public GenericComparer(string sortColumn, SortOrder sortingOrder)
    //    {
    //        this.sortColumn = sortColumn;
    //        this.sortingOrder = sortingOrder;
    //    }

    //    #endregion

    //    #region public property

    //    /// <summary>
    //    /// Column Name(public property of the class) to be sorted.
    //    /// </summary>

    //    public string SortColumn
    //    {
    //        get { return sortColumn; }
    //    }

    //    /// <summary>
    //    /// Sorting order.
    //    /// </summary>

    //    public SortOrder SortingOrder
    //    {
    //        get { return sortingOrder; }
    //    }

    //    #endregion

    //    #region public methods

    //    /// <summary>
    //    /// Compare interface implementation
    //    /// </summary>
    //    /// <param name="x">custom Object</param>
    //    /// <param name="y">custom Object</param>
    //    /// <returns>int</returns>

    //    //public int Compare(T x, T y)
    //    //{

    //    //    PropertyInfo propertyInfo = typeof(T).GetProperty(sortColumn);
    //    //    IComparable obj1 = (IComparable)propertyInfo.GetValue(x, null);
    //    //    IComparable obj2 = (IComparable)propertyInfo.GetValue(y, null);
    //    //    if (sortingOrder == SortOrder.Ascending)
    //    //    {
    //    //        return (obj1.CompareTo(obj2));
    //    //    }
    //    //    else
    //    //    {
    //    //        return (obj2.CompareTo(obj1));
    //    //    }
    //    //}

    //    #endregion



    //}
}